﻿<!DOCTYPE html>
<html>
<head>
    <title>SORT Function</title>
	<meta charset="utf-8" />
	<meta name="description" content="The SORT function is one of the lookup and reference functions. Learn how to use the SORT function in Excel sheets and compatible files with ONLYOFFICE." />
	<link type="text/css" rel="stylesheet" href="../../../../../../common/main/resources/help/editor.css" />
	<link type="text/css" rel="stylesheet" href="../../images/sprite.css" />
	<script type="text/javascript" src="../callback.js"></script>
	<script type="text/javascript" src="../search/js/page-search.js"></script>
</head>
<body>
    <div class="mainpart">
        <div class="search-field">
            <input id="search" class="searchBar" placeholder="Search" type="text" onkeypress="doSearch(event)">
        </div>
        <h1>SORT Function</h1>
        <p>The <b>SORT</b> function is one of the <a href="../UsageInstructions/InsertFunction.htm#lookupreference" onclick="onhyperlinkclick(this)">lookup and reference functions</a>. It is used to sort a range of data or an array and to return the sorted array.</p>
        <h3>Syntax</h3>
        <p><b><em>SORT(array, [sort_index], [sort_order], [by_col])</em></b></p>
        <p>The <b>SORT</b> function has the following arguments:</p>
        <table style="width: 40%">
            <tr>
                <th style="background-color: #f4f4f4" width="150ch"><b>Argument</b></th>
                <th style="background-color: #f4f4f4"><b>Description</b></th>
            </tr>
            <tr>
                <td><b><em>array</em></b></td>
                <td>The range of data to sort.</td>
            </tr>
            <tr>
                <td><b><em>sort_index</em></b></td>
                <td>An optional argument. A number identifying the column or the row to sort by.</td>
            </tr>
            <tr>
                <td><b><em>sort_order</em></b></td>
                <td>An optional argument. A number determining the sorting order:
                    <ul>
                        <li>1 or omitted for ascending order (by default),</li>
                        <li>-1 for descending order.</li>
                    </ul>
                </td>
            </tr>
            <tr>
                <td><b><em>by_col</em></b></td>
                <td>An optional argument. A value indicating the sorting direction:
                    <ul>
                        <li>FALSE or omitted for sorting by rows when your data is organized vertically.</li>
                        <li>TRUE for sorting by columns when your data is organized horizontally.</li>
                    </ul>
                </td>
            </tr>
        </table>        

        <h3>Notes</h3>        
        <p>Please note that this is an array formula. To learn more, please read the <a href="../UsageInstructions/InsertArrayFormulas.htm" onclick="onhyperlinkclick(this)">Insert array formulas</a> article.</p>
        <p><a href="../UsageInstructions/InsertFunction.htm#applyfunction" onclick="onhyperlinkclick(this)">How to apply</a> the <b>SORT</b> function.</p>
        
        <h3>Examples</h3>
            <p>The figure below displays the result returned by the <b>SORT</b> function.</p>
        <p><img alt="SORT Function" src="../images/sort.png" /></p>
    </div>
</body>
</html>